unit kargorapor;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  wwdblook, StdCtrls, wwdbdatetimepicker, Db, ADODB, ppCtrls, ppBands,
  ppVar, ppPrnabl, ppClass, ppCache, ppProd, ppReport, ppComm, ppRelatv,
  ppDB, ppDBPipe, Grids, Wwdbigrd, Wwdbgrid, Buttons, ppViewr,
  ExtCtrls, TXComp, TXRB;

type
  Tkargoraporf = class(TForm)
    Label15: TLabel;
    Label14: TLabel;
    BitTar: TwwDBDateTimePicker;
    basTar: TwwDBDateTimePicker;
    ppDBPipeline1: TppDBPipeline;
    report: TppReport;
    qteklst: TADOQuery;
    qteklsts: TDataSource;
    wwDBGrid1: TwwDBGrid;
    Button1: TButton;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand1: TppDetailBand;
    ppFooterBand1: TppFooterBand;
    ppTitleBand1: TppTitleBand;
    ppLabel1: TppLabel;
    ppSystemVariable1: TppSystemVariable;
    ppSystemVariable2: TppSystemVariable;
    ppDBText1: TppDBText;
    ppLabel2: TppLabel;
    ppDBText2: TppDBText;
    ppLabel3: TppLabel;
    ppLine1: TppLine;
    ppLine2: TppLine;
    ppSummaryBand1: TppSummaryBand;
    ppLabel4: TppLabel;
    ppDBCalc1: TppDBCalc;
    BitBtn1: TBitBtn;
    Button2: TButton;
    Bevel1: TBevel;
    StaticText1: TLabel;
    ExtraOptions1: TExtraOptions;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button1Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure reportPreviewFormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  kargoraporf: Tkargoraporf;

implementation

uses kargorap;

{$R *.DFM}

procedure Tkargoraporf.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  action := cafree;
  kargoraporf := nil;

end;

procedure Tkargoraporf.Button1Click(Sender: TObject);
var
  toplam: integer;
begin
  qTekLst.Close;
  qTekLst.SQL.Clear;
  qTekLst.SQL.Add('select count(*) as adet,kargoadi=(select karadi from kargo where karkod=teknik.gelkargokod) from teknik where (gelisi=''K'') ');
  qTekLst.SQL.Add('and (tarih>:bastar) and (tarih<:bittar)');
  qTekLst.Parameters.ParamByName('BasTar').datatype := ftDate;
  qTekLst.Parameters.ParamByName('BitTar').datatype := ftDate;
  qTekLst.Parameters.ParamByName('BasTar').value := BasTar.date;
  qTekLst.Parameters.ParamByName('BitTar').value := BitTar.date + 1;
  qTekLst.SQL.Add('group by gelkargokod');
  qTekLst.SQL.Add('order by adet');
  qTekLst.open;

  qTekLst.first;
  qTekLst.DisableControls;
  toplam := 0;
  while not qTekLst.eof do
  begin
    toplam := toplam + qTekLst.fieldbyname('adet').asinteger;
    qTekLst.next;
  end;

  qTekLst.enableControls;

  statictext1.Caption := '(Toplam:' + inttostr(toplam) + ')';
  wwDBGrid1.SetFocus;

end;

procedure Tkargoraporf.BitBtn1Click(Sender: TObject);
begin
  qTekLst.DisableControls;
  report.print;
  qTekLst.enableControls;

end;

procedure Tkargoraporf.reportPreviewFormCreate(Sender: TObject);
begin
  Report.PreviewForm.WindowState := wsMaximized;
  //  TppViewer(Report.PreviewForm.Viewer).ZoomSetting := zs100Percent;

end;

procedure Tkargoraporf.Button2Click(Sender: TObject);
begin
  close;
end;

end.

